using System;
using System.Collections.Generic;

namespace OffsetPath
{
    public class ClassAd : ClassAk
    {
        public PuntoDueD a;
        public PuntoDueD b;
        public PuntoDueD c;

        public ClassAd()
        {
            this.a = new PuntoDueD();
            this.b = new PuntoDueD();
            this.c = new PuntoDueD();
        }

        public ClassAd(PuntoDueD A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            this.a = new PuntoDueD();
            this.b = new PuntoDueD();
            this.c = new PuntoDueD();
            this.l().e(A_0);
            this.o().e(A_1);
            this.f().e(A_2);
        }

        public bool MethodA(PuntoDueD A_0)
        {
            bool flag = this.p() < 0.0;
            if ((e(this.l(), this.o(), A_0) < 0.0) ^ flag)
            {
                return false;
            }
            if ((e(this.o(), this.f(), A_0) < 0.0) ^ flag)
            {
                return false;
            }
            if ((e(this.f(), this.l(), A_0) < 0.0) ^ flag)
            {
                return false;
            }
            return true;
        }

        public double MethodA(PuntoDueD A_0, PuntoDueD A_1)
        {
            double num = this.p();
            bool flag = true;
            ForseLineaClassA classA = new ForseLineaClassA(this.l(), this.o());
            ForseLineaClassA a2 = new ForseLineaClassA(this.o(), this.f());
            ForseLineaClassA a3 = new ForseLineaClassA(this.f(), this.l());
            if (num == 0.0)
            {
                double num2 = classA.g();
                double num3 = a2.g();
                double num4 = a3.g();
                if ((num2 > num3) && (num2 > num4))
                {
                    return classA.MethodD(A_0, A_1);
                }
                if (num3 > num4)
                {
                    return a2.MethodD(A_0, A_1);
                }
                return a3.MethodD(A_0, A_1);
            }
            bool flag2 = num < 0.0;
            ForseLineaClassA a4 = null;
            ForseLineaClassA a5 = null;
            if (classA.MethodB(A_0) ^ flag2)
            {
                a4 = classA;
            }
            if (a2.MethodB(A_0) ^ flag2)
            {
                if (a4 != null)
                {
                    a5 = a2;
                }
                else
                {
                    a4 = a2;
                }
            }
            if (a3.MethodB(A_0) ^ flag2)
            {
                if (a4 != null)
                {
                    a5 = a3;
                }
                else
                {
                    a4 = a3;
                }
            }
            if (a4 == null)
            {
                PuntoDueD puntoDueD = new PuntoDueD();
                bool flag3 = false;
                double num5 = 0.0;
                if (A_0.MethodA(classA, puntoDueD, ref flag))
                {
                    num5 = A_0.MethodC(puntoDueD);
                    A_1.e(puntoDueD);
                    flag3 = true;
                }
                if (A_0.MethodA(a2, puntoDueD, ref flag))
                {
                    double num6 = A_0.MethodC(puntoDueD);
                    if (!flag3 || (num6 < num5))
                    {
                        num5 = num6;
                        A_1.e(puntoDueD);
                        flag3 = true;
                    }
                }
                if (A_0.MethodA(a3, puntoDueD, ref flag))
                {
                    double num7 = A_0.MethodC(puntoDueD);
                    if (!flag3 || (num7 < num5))
                    {
                        num5 = num7;
                        A_1.e(puntoDueD);
                        flag3 = true;
                    }
                }
                return -num5;
            }
            if (a5 == null)
            {
                return a4.MethodD(A_0, A_1);
            }
            PuntoDueD x2 = new PuntoDueD();
            if (A_0.MethodA(a4, x2, ref flag))
            {
                A_1 = x2;
                return x2.MethodC(A_0);
            }
            if (A_0.MethodA(a5, x2, ref flag))
            {
                A_1 = x2;
                return x2.MethodC(A_0);
            }
            if (a4 == classA)
            {
                if (a5 == a2)
                {
                    A_1 = this.o();
                    return A_0.MethodC(this.o());
                }
                A_1 = this.l();
                return A_0.MethodC(this.l());
            }
            A_1 = this.f();
            return A_0.MethodC(this.f());
        }

        public double MethodA(ClassAd A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            PuntoDueD puntoDueD = new PuntoDueD();
            double num = this.MethodA(A_0.l(), A_1);
            A_2.e(A_0.l());
            double num2 = this.MethodA(A_0.o(), puntoDueD);
            if (num2 < num)
            {
                A_2.e(A_0.o());
                A_1.e(puntoDueD);
                num = num2;
            }
            num2 = this.MethodA(A_0.f(), puntoDueD);
            if (num2 < num)
            {
                A_2.e(A_0.f());
                A_1.e(puntoDueD);
                num = num2;
            }
            num2 = A_0.MethodA(this.l(), puntoDueD);
            if (num2 < num)
            {
                A_2.e(puntoDueD);
                A_1.e(this.l());
                num = num2;
            }
            num2 = A_0.MethodA(this.o(), puntoDueD);
            if (num2 < num)
            {
                A_2.e(puntoDueD);
                A_1.e(this.o());
                num = num2;
            }
            num2 = A_0.MethodA(this.f(), puntoDueD);
            if (num2 < num)
            {
                A_2.e(puntoDueD);
                A_1.e(this.f());
                num = num2;
            }
            return num;
        }

        public static bool MethodA(PuntoDueD A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            return (e(A_0, A_1, A_2) < 0.0);
        }

        public PuntoDueD MethodB()
        {
            return d(this.l(), this.o(), this.f());
        }

        public static PuntoDueD MethodB(PuntoDueD A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            ForseLineaClassA classA = new ForseLineaClassA(A_0, A_1);
            classA.MethodA(new ForseLineaClassA(A_0, A_2).g());
            ForseLineaClassA a2 = new ForseLineaClassA(A_0, A_2.MethodA(classA.i()));
            ForseLineaClassA a3 = new ForseLineaClassA(A_1, A_0);
            a3.MethodA(new ForseLineaClassA(A_1, A_2).g());
            ForseLineaClassA a4 = new ForseLineaClassA(A_1, A_2.MethodA(a3.i()));
            List<PuntoDueD> list = new List<PuntoDueD>();
            bool flag = true;
            bool flag2 = true;
            a2.MethodA(a4, list, ref flag, ref flag2, true);
            return list[0];
        }

        public double MethodC()
        {
            return ((this.l().MethodC(this.o()) + this.o().MethodC(this.f())) + this.f().MethodC(this.l()));
        }

        public override double MethodC(PuntoDueD A_0)
        {
            PuntoDueD puntoDueD = new PuntoDueD();
            return this.MethodA(A_0, puntoDueD);
        }

        public static PuntoDueD MethodC(PuntoDueD A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            ForseLineaClassA classA = new ForseLineaClassA(A_0, A_1);
            ForseLineaClassA a2 = new ForseLineaClassA(A_1, A_2);
            ForseLineaClassA a3 = new ForseLineaClassA(A_2, A_0);
            double num = ClassK.s - classA.b.e(a2.b);
            if (num >= ClassK.ae)
            {
                return new PuntoDueD(A_1);
            }
            if (num < ClassK.ac)
            {
                double num2 = ClassK.s - a2.b.e(a3.b);
                if (num2 >= ClassK.ae)
                {
                    return new PuntoDueD(A_2);
                }
                if (((ClassK.s - num) - num2) >= ClassK.ae)
                {
                    return new PuntoDueD(A_0);
                }
            }
            if (classA.MethodB(A_2))
            {
                classA.b.c(ClassK.ac);
                a2.b.c(ClassK.ac);
            }
            else
            {
                classA.b.MethodB(ClassK.ac);
                a2.b.MethodB(ClassK.ac);
            }
            classA.MethodA(A_2);
            a2.MethodA(A_0);
            List<PuntoDueD> list = new List<PuntoDueD>();
            bool flag = true;
            bool flag2 = true;
            if (classA.MethodA(a2, list, ref flag, ref flag2, false))
            {
                return list[0];
            }
            return new PuntoDueD(0.0, 0.0);
        }

        public PuntoDueD d()
        {
            return MethodC(this.l(), this.o(), this.f());
        }

        public static PuntoDueD d(PuntoDueD A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            ForseLineaClassA classA = new ForseLineaClassA(A_0, A_1);
            ForseLineaClassA a2 = new ForseLineaClassA(A_1, A_2);
            classA.a.e(classA.p());
            a2.a.e(a2.p());
            classA.b.MethodB();
            a2.b.MethodB();
            List<PuntoDueD> list = new List<PuntoDueD>();
            bool flag = true;
            bool flag2 = true;
            classA.MethodA(a2, list, ref flag, ref flag2, true);
            PuntoDueD puntoDueD = new PuntoDueD(0.0, 0.0);
            if (list.Count == 1)
            {
                puntoDueD = list[0];
            }
            return puntoDueD;
        }

        public bool e()
        {
            return (this.p() < 0.0);
        }

        public static double e(PuntoDueD A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            double num = (((((A_0.X * A_1.Y) - (A_1.X * A_0.Y)) + (A_1.X * A_2.Y)) - (A_2.X * A_1.Y)) + (A_2.X * A_0.Y)) - (A_0.X * A_2.Y);
            return (num / 2.0);
        }

        public PuntoDueD f()
        {
            return this.c;
        }

        public override void f(ClassAb A_0)
        {
            A_0.MethodB(this.l());
            A_0.e(this.o());
            A_0.e(this.f());
        }

        public static bool f(PuntoDueD A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            return (e(A_0, A_1, A_2) == 0.0);
        }

        ~ClassAd()
        {
        }

        public void g(PuntoDueD A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            this.l().e(A_0);
            this.o().e(A_1);
            this.f().e(A_2);
        }

        public double j()
        {
            return Math.Abs(e(this.l(), this.o(), this.f()));
        }

        public PuntoDueD k()
        {
            return MethodB(this.l(), this.o(), this.f());
        }

        public override void k(ForseLineaClassA classA0, ClassAj A_1)
        {
            this.l().k(classA0, A_1);
            A_1.MethodB(this.o().MethodB(classA0));
            A_1.MethodB(this.f().MethodB(classA0));
        }

        public PuntoDueD l()
        {
            return this.a;
        }

        public override void l(ClassAtPuntoIncrementale A_0, ClassAj A_1)
        {
            this.l().l(A_0, A_1);
            A_1.MethodB(this.o().MethodA(A_0));
            A_1.MethodB(this.f().MethodA(A_0));
        }

        public bool n()
        {
            return (this.p() == 0.0);
        }

        public override void n(ClassAg A_0)
        {
            this.l().n(A_0);
            this.o().n(A_0);
            this.f().n(A_0);
        }

        public PuntoDueD o()
        {
            return this.b;
        }

        public override void o(double A_0, PuntoDueD A_1)
        {
            this.l().o(A_0, A_1);
            this.o().o(A_0, A_1);
            this.f().o(A_0, A_1);
        }

        public double p()
        {
            return e(this.l(), this.o(), this.f());
        }

        public override void p(ClassAtPuntoIncrementale A_0)
        {
            this.l().p(A_0);
            this.o().p(A_0);
            this.f().p(A_0);
        }

        public override void q(ForseLineaClassA classA0)
        {
            this.l().q(classA0);
            this.o().q(classA0);
            this.f().q(classA0);
        }

        public override void r(PuntoDueD A_0)
        {
            this.l().r(A_0);
            this.o().r(A_0);
            this.f().r(A_0);
        }

        public override void GetStartPoint(double A_0, PuntoDueD A_1)
        {
            this.l().GetStartPoint(A_0, A_1);
            this.o().GetStartPoint(A_0, A_1);
            this.f().GetStartPoint(A_0, A_1);
        }
    }
}

